import { createContext, useContext, useState } from "react";

// 使用元组类型定义 context 的类型
const DnDContext = createContext<[string | null, (value: string | null) => void]>([null, () => {}]);

// 为 children 添加 React.ReactNode 类型
export const DnDProvider = ({ children }: { children: React.ReactNode }) => {
  const [type, setType] = useState<string | null>(null);

  return (
    <DnDContext.Provider value={[type, setType]}>
      {children}
    </DnDContext.Provider>
  );
};

export default DnDContext;

export const useDnD = () => {
  return useContext(DnDContext);
};